package org.example.myleet.p1656;

import java.util.ArrayList;
import java.util.List;

public class OrderedStream {

    private String[] store;

    private int id;

    public OrderedStream(int n) {
        store = new String[n + 2];
        id = 1;
    }

    public List<String> insert(int idKey, String value) {
        List<String> res = new ArrayList<>();
        store[idKey] = value;
        if (id == idKey) {
            while (null != store[id]){
                res.add(store[id++]);
            }
        }
        return res;
    }
}
